import { Scene } from "../../../../../../Core/Module/Entity/Scene";
import { SceneType } from "../../../../../../Core/Module/Entity/SceneType";
import { ActorMessageHandlerAttribute } from "../../../../../../Decorator/Decorator";
import { ETTask } from "../../../../../../Support/Share/Lib/Async/ETTask";
import { R2G_GetLoginKey, G2R_GetLoginKey } from "../../../../../Model/Generate/Share/Message/InnerMessage_S_20001";
import { GateSessionKeyComponent } from "../../../../../Model/Server/Demo/Gate/GateSessionKeyComponent";
import { AMActorRpcHandler } from "../../../Module/Actor/AMActorRpcHandler";

@ActorMessageHandlerAttribute(SceneType.Gate, R2G_GetLoginKey, G2R_GetLoginKey)
export class R2G_GetLoginKeyHandler extends AMActorRpcHandler<Scene, R2G_GetLoginKey, G2R_GetLoginKey> {

    protected async Run(scene: Scene, request: R2G_GetLoginKey, response: G2R_GetLoginKey): Promise<any> {
        // console.log(`R2G_GetLoginKeyHandler.Run`);

        let key = 999000001;
        scene.GetComponent<GateSessionKeyComponent>(GateSessionKeyComponent).Add(key, request.Account);
        response.Key = key;
        response.GateId = scene.Id;
        await ETTask.CompletedTask;
    }

}